﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
      <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Free Bootstrap Admin Template : Dream</title>
    <!-- Bootstrap Styles-->
    <link href="/static/css/bootstrap.min.css" rel="stylesheet" />
    <!-- FontAwesome Styles-->
    <link href="/static/css/font-awesome.css" rel="stylesheet" />
     <!-- Morris Chart Styles-->
    <!-- Custom Styles-->
    <link href="/static/css/custom-styles.css" rel="stylesheet" />
     <!-- Google Fonts-->
   <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
     <!-- TABLE STYLES-->
    <link href="/static/js/dataTables/dataTables.bootstrap.css" rel="stylesheet" />
    <!--         vue-->
    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.10/dist/vue.js"></script>
    <!--         axios-->
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>
<body>
    <div id="wrapper">
        <nav class="navbar navbar-default top-navbar" role="navigation">
            <div th:insert="~{common/common::admin-top}"></div>
        </nav>
        <!--/. NAV TOP  -->
        <nav class="navbar-default navbar-side" role="navigation">
            <div th:insert="~{common/common::admin-left}"></div>
        </nav>
        <!-- /. NAV SIDE  -->
        <div id="page-wrapper" >
            <div id="page-inner">
			 <div class="row">
                    <div class="col-md-12">
                        <h1 class="page-header">
                            用户管理 <small>user manager</small>
                        </h1>
                    </div>
                </div> 
                 <!-- /. ROW  -->
               
            <div class="row" id="app">
                <div class="col-md-12">
                    <!-- Advanced Tables -->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                             所有用户
                        </div>
                        <div class="panel-body">
                            <div class="table-responsive">
                                <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                    <thead>
                                        <tr>
                                            <th>用户编号</th>
                                            <th>用户名</th>
                                            <th>用户密码</th>
                                            <th>联系电话</th>
                                            <th>地址</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr class="gradeA" v-for="item in userList">
                                            <td>{{item.userId}}</td>
                                            <td>{{item.username}}</td>
                                            <td>{{item.password}}</td>
                                            <td class="center">{{item.telephone}}</td>
                                            <td class="center">{{item.address}}</td>
                                            <td class="center">
                                                <button @click="delUser(item.userId)">删除</button>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                            
                        </div>
                    </div>
                    <!--End Advanced Tables -->
                </div>
            </div>
                <!-- /. ROW  -->
        </div>
               <footer>@猫咖管理控制台</p></footer>
    </div>
             <!-- /. PAGE INNER  -->
            </div>
         <!-- /. PAGE WRAPPER  -->
     <!-- /. WRAPPER  -->
    <!-- JS Scripts-->
    <!-- jQuery Js -->
    <script src="/static/js/jquery-1.10.2.js"></script>
    <!-- Bootstrap Js -->
    <script src="/static/js/bootstrap.min.js"></script>
    <!-- Metis Menu Js -->
    <script src="/static/js/jquery.metisMenu.js"></script>
     <!-- DATA TABLE SCRIPTS -->
    <script src="/static/js/dataTables/dataTables.bootstrap.js"></script>
    <script src="/static/js/dataTables/dataTables.bootstrap.js"></script>
        <script>
            $(document).ready(function () {
                $('#dataTables-example').dataTable();
            });
    </script>
    <!-- Custom Js -->
    <script src="/static/js/custom-scripts.js"></script>
<script>
    let vm = new Vue({
        el:'#app',
        data:{
            userList:[]
        },
        methods:{
            delUser(userId){
                let that = this
                axios.delete('/user/delUser/'+userId).then(res=>{
                    if (res.data){
                        alert("用户已删除")
                        axios.get('/user/allUser').then(res=>{
                            that.userList = res.data
                        })
                    }
                })
            }
        },
        mounted(){
            let that = this
            axios.get('/user/allUser').then(res=>{
                that.userList = res.data
            })
        }
    })
</script>
    
   
</body>
</html>
